<!--
  ~ Copyright (c) 2020 the original author or authors
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      https://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  ~ or implied. See the License for the specific language governing
  ~ permissions and limitations under the License.
  -->

<div *ngIf="app" class="breadcrumbs mat-body-2">
  <div *ngIf="modelSelected; else onlyApp" class="breadcrumbs--container">
    <a class="link" (click)="onNavigate(routes.Home)">{{ 'breadcrumbs.home' | translate }}</a>
    <div class="separator">></div>
    <a
      class="link"
      matTooltip="{{ app.name }}"
      matTooltipClass="top-arrow"
      [matTooltipDisabled]="app.name.length <= maxNameLength"
      (click)="onNavigate(routes.Application, app.id)"
    >
      {{ app.name }}
    </a>
    <div class="separator">></div>
    <div
      *ngIf="model"
      class="link current"
      matTooltip="{{ model.name }}"
      matTooltipClass="top-arrow"
      [matTooltipDisabled]="model.name.length <= maxNameLength"
    >
      {{ model.name }}
    </div>
  </div>
  <ng-template #onlyApp>
    <div class="breadcrumbs--container">
      <a class="link" (click)="onNavigate(routes.Home)">{{ 'breadcrumbs.home' | translate }}</a>
      <div class="separator">></div>
      <div
        class="link current"
        matTooltip="{{ app.name }}"
        matTooltipClass="top-arrow"
        [matTooltipDisabled]="app.name.length <= maxNameLength"
      >
        {{ app.name }}
      </div>
    </div>
    <ng-container *ngIf="app && !hideControls">
      <div class="breadcrumbs--actions">
        <ng-container *ngIf="currentUserRole && currentUserRole !== role.User">
          <button type="button" (click)="appSettings.emit(app)">
            <mat-icon
              svgIcon="settings"
              matTooltip="{{ 'common.capital.edit' | translate }}"
              [matTooltipPosition]="'above'"
              matTooltipClass="bottom-arrow"
            ></mat-icon>
          </button>
        </ng-container>
        <button type="button" (click)="usersList.emit(app)">
          <mat-icon
            svgIcon="user-icon"
            matTooltip="{{ 'users.manage.manage_users_title' | translate }}"
            [matTooltipPosition]="'above'"
            matTooltipClass="bottom-arrow"
          ></mat-icon>
        </button>
      </div>
    </ng-container>
  </ng-template>
</div>
